#version 330 core
in vec4 FragPos;

uniform vec3 lightPos;
uniform float far_plane;

void main()
{
    // 计算片段与光源之间的距离
    float lightDistance = length(FragPos.xyz - lightPos);
    
    // 通过除以远平面值映射到[0,1]范围
    lightDistance = lightDistance / far_plane;
    
    // 将其写入作为修改后的深度
    gl_FragDepth = lightDistance;
}